package com.compunit.composite;

import java.util.concurrent.TimeUnit;

import org.compunit.Provide;
import org.compunit.interfaces.IComponent;
import org.compunit.interfaces.IResourceRetriever;

import com.compunit.composite.b.interfaces.ITimer;

/**
 * <code>NanoTimer</code> defines the implementation
 * of a timer unit that uses nanosecond as its base
 * time unit. It extends <code>AbstractTimer</code>
 * to inherit the thread safe time value calculation
 * implementation.
 *
 * @author Yi Wang (Neakor)
 * @version Creation date: 07-07-2009 22:24 PST
 * @version Modified date: 07-07-2009 22:25 PST
 */
@Provide({ITimer.class})
public class NanoTimer extends AbstractTimer {
	
	/**
	 * Constructor of <code>NanoTimer</code>.
	 */
	public NanoTimer() {}

	@Override
	protected long getCurrent() {
		return System.nanoTime();
	}

	@Override
	public TimeUnit getUnit() {
		return TimeUnit.NANOSECONDS;
	}

	@Override
	public boolean activate(final IResourceRetriever handler) throws Exception {
		return true;
	}

	@Override
	public boolean connect(final IComponent unit, final String interfaceName) throws Exception {
		return true;
	}

	@Override
	public void deactivate() throws Exception {}
}
